package com.manor.main.utils;

import android.graphics.Color;
import android.os.CountDownTimer;
import android.widget.TextView;

public class CodeTimeCount extends CountDownTimer {
    private TextView code_text;
    private boolean isTick;
    private String strColor = "#F3941C";

    public CodeTimeCount(long millisInFuture, long countDownInterval, TextView code) {
        super(millisInFuture, countDownInterval);
        code_text = code;
    }

    public CodeTimeCount(long millisInFuture, long countDownInterval, TextView code, String colors) {
        super(millisInFuture, countDownInterval);
        code_text = code;
        strColor = colors;
    }


    @Override
    public void onTick(long millisUntilFinished) {
        isTick = true;
        code_text.setClickable(false);
        code_text.setTextColor(Color.parseColor(strColor));
        code_text.setText((millisUntilFinished / 1000) + "s");
    }

    @Override
    public void onFinish() {
        isTick = false;
        code_text.setTextColor(Color.parseColor(strColor));
        code_text.setText("重新获取");
        code_text.setClickable(true);
    }

    public boolean isOnTick() {
        return isTick;
    }
}
